function exportData(url, form) {
    var str = "";
    if (url.indexOf("?") >= 0) {
        var str = "";
    } else {
        var str = "?";
    }
    var data = Object.assign({}, form);
    for (var o in data) {
        if (data[o]) {
            str += (o + "=" + data[o] + "&");
        }
    }
    str = str.substring(0, str.length - 1);
    window.location.href = url + str;
}

Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "H+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}


function getRootPath() {
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8083
    var localhostPaht = curWwwPath.substring(0, pos);
    //获取带"/"的项目名，如：/uimcardprj
	var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1)  +"/";
   // var projectName = "/";
    console.log("huang=====================rootpath == == = "+ (localhostPaht + projectName))
    return(localhostPaht + projectName);
}

function stringFormat(v) {
    return v.replace(/[A-Z]/, function (word) {
        return "_" + word.toLowerCase();
    });
}

Vue.component('ex-select-enum', {
    props: ['value', 'enumCd', 'enumArr', 'size', 'placeholder'],
    template: '<el-select clearable :size="size" v-model="value" :placeholder="placeholder" @change="vChange">\
		<el-option\
	      v-for="item in options"\
	      :label="item.enumName"\
	      :value="item.enumCd">\
	    </el-option>\
	  </el-select>',
    data: function () {
        return {
            options: []
        }
    },
    created: function () {
        if (this.enumArr) {
            this.options = eval(this.enumArr);
        } else if (this.enumCd) {
            $.post(getRootPath() + 'backstage/enum/queryEnumDetail', {
                'enumCd': this.enumCd
            }, function (obj) {
                if (obj.success) {
                    this.options = obj.data;
                }
            }.bind(this), 'json');
        }
    },
    methods: {
        vChange: function (v) {
            this.$emit('input', v);
        }
    }
});

Vue.component('ex-table-column-enum', {
    props: ['prop', 'label', 'width', 'enumCd', 'enumArr'],
    template: '<el-table-column :prop="prop" :label="label" :min-width="width">\
			<template scope="scope">\
				<span v-for = "item in arr" v-if="item.enumCd==scope.row[prop]">{{item.enumName}}</span>\
			</template>\
		</el-table-column>',
    data: function () {
        return {
            arr: []
        }
    },
    created: function () {
        if (this.enumArr) {
            if (this.enumArr instanceof Array) {
                this.arr = this.enumArr;
            } else {
                this.arr = eval(this.enumArr);
            }
        } else if (this.enumCd) {
            $.post(getRootPath() + 'backstage/enum/queryEnumDetail', {
                'enumCd': this.enumCd
            }, function (obj) {
                if (obj.success) {
                    this.arr = obj.data;
                }
            }.bind(this), 'json');
        }
    }
});

Vue.component('ex-radio-enum', {
    props: ['value', 'enumCd', 'enumArr'],
    template: '<el-radio-group v-model="value" @change="vChange"><el-radio v-for="item in arr" :label="item.enumCd">{{item.enumName}}</el-radio></el-radio-group>',
    data: function () {
        return {
            arr: []
        }
    },
    created: function () {
        if (this.enumArr) {
            this.arr = eval(this.enumArr);
        } else if (this.enumCd) {
            $.post(getRootPath() + 'backstage/enum/queryEnumDetail', {
                'enumCd': this.enumCd
            }, function (obj) {
                if (obj.success) {
                    this.arr = obj.data;
                }
            }.bind(this), 'json');
        }
    },
    methods: {
        vChange: function (v) {
            this.$emit('input', v);
        }
    }
});

Vue.component('ex-table-column-enum-tag', {
    props: ['prop', 'label', 'width', 'enumCd', 'color', 'enumArr'],
    template: '<el-table-column :prop="prop" :label="label" :min-width="width">\
			<template scope="scope">\
				<el-tag :type="item.color" v-for = "item in arr" size="small" v-if="item.enumCd==scope.row[prop]">{{item.enumName}}</el-tag>\
			</template>\
		</el-table-column>',
    data: function () {
        return {
            arr: [],
            color: [],
        }
    },
    created: function () {
        var color = this.color;
        if (!color) {
            color = "['primary', 'success', 'info', 'warning', 'danger', '']";
        }
        color = eval(color);

        if (this.enumArr) {
            this.arr = eval(this.enumArr);
            for (var i = 0; i < this.arr.length; i++) {
                this.arr[i].color = this.color[i];
            }
        } else if (this.enumCd) {
            $.post(getRootPath() + 'backstage/enum/queryEnumDetail', {'enumCd': this.enumCd}, function (obj) {
                if (obj.success) {
                    this.arr = obj.data;
                    for (var i = 0; i < this.arr.length; i++) {
                        this.arr[i].color = color[i];
                    }
                }
            }.bind(this), 'json');
        }

    }
});